starting to rewrite validation code using State monad