Modified to store positions as coordinate pairs (rather than separately)