correcting null pointer exception