Refactor coordinates to use flexible variables