Switched from using Threads to using Tasks