Changed code to use xy structure.