Formation Tracking in Javascript