make sure final element is included in the query