Code check handler

Tidied it up a bit as it wouldn't compile.

Got it to return all errors instead of doing a check then returning any errors etc I can change it back if you prefer