Added easier isValid-function.

Look at this.
It's much shorter and (as I think) cleaner!