fix some error handling on bad input