added Query task and ppolish some more code