cleaned-up task code