Updated to work correctly with anchor coordinates