Code cleanup.
preventing possible null pointer errors