Fixed possible null pointer exeption.