refactor register and edit profile functions