Separate toolbar getting XY coords logic in a function