fixed query, closed resources