added error handling if username invalid