handling null pointer exception