Added timeout value for waiting for user input
Made checking user input more efficient