refactor of password resetting