almost finished the multitracking algorithm