Fixed null query issue