added input error function and passed tests