Refactor password resetting