fixed handling of bad input