refactor to improve the code used to create the users