invalid input check added