Refactor validateInput
finish refactor
remove old code