refactor saving users to db