VID-957 Fix the query