Ported the tick handler