Added error handling for input values