Optimize code for creating or updating user