Added comments for each function and login now returns at the end of the list