fixed the main tracking code