Added error checking for input