Fixed a possible null pointer exception