Moved validation stuff to external file