Refactored the code. Implemented the multistep authentication.