added function comments
proper task cleanup