Preventing null issue on query.