query method to execute block in both environments