fix undefineds in query