start refactoring restore password code