added more error checking for incompatible assignments etc