checks for invalid input, fixed bug where 1st input was removed