Add error handling for incorrect password. Refactoring.