 American songwriter and producer Christopher " Tricky " Stewart convened with Terius " The @-@ Dream " Nash and Kuk Harrell in January 2007 at the Atlanta @-@ based Triangle Studios to create new material . In the studio , Stewart was " messing around with a walloping hi @-@ hat sound " , which he found in the free music software GarageBand , which is included in all Mac computers . With his attention caught by the sound , Nash asked Stewart what he was doing : " Oh , my Gosh , what is that beat ? " . When Stewart incorporated chords onto the hi @-@ hat , " immediately the word popped into [ Nash 's ] head " ; he went to the vocal booth and started singing . Nash wrote the first two verses and the chorus over Stewart 's skeleton track . They quickly wrote the lyrics , completing the first verse in 60 seconds . They continued into writing , adding the hook while " [ Stewart ] would put the next chord " . In a matter of hours , they had recorded a demo of the track . The song was written with American pop singer Britney Spears in mind , whom Stewart had previously worked with on her 2003 single " Me Against the Music " . Stewart and Nash thought that Spears , who had " her personal life ... a little out of control " at the time , needed a hit as musical comeback . Spears was working on her fifth album , Blackout , so they sent a copy of the demo to Spears ' management . However , Spears did not hear of the song because her label rejected it , claiming they had enough songs for her to record . 
