It was written by Usher , Savan Kotecha , Max Martin and Shellback , with production handled by the latter two .
It was written by Max Martin , Shellback , Savan Kotecha , and Usher .