Added login failure handling and cleaned up unnecessary comments