finished validation code