added changes to checkForNull function