Added error check for null fields during login