fixing a bug to detect bad input