Fixed systnax error in query