added error handeling for login