Fix custom fields query