preventing undefined query