Add release resource in query/iterate functions