Correction of Null pointer exception