added restore_env to single query planner