fix query for ar