refactored from Thread to Task