added null exception to queries