added tracking system. Still needs polish and integration in the main function