added error handling for input