improve flow of track function