Fixed casting exception in TimedTask