NULL Pointer Error fixed