changed managedtask class to template, but was no good