refactor forgot password function