fixed invalid input problem