Updated TaskManager.cs' Tick method