extract X and Y using the same script