Fix for error caused when a query returned null.