Input error checking added