moved the checking stuff to a checkValid

also fixed some other syntax stuff