added code to prevent attempts to load a null into the database