Refactor showing error on bad input