Fully commented the login code