handle null pointer exception in MongoDB Storage