Added fix to the Null pointer exception