Moved validation code