Rewrite of errorCheck function, to make it: correct, more detailed and