query only if list is not empty