refactoring create and update func in users controller