replace 'data' object with 'user' object, tidy up related code because it was embarrassing