Refactored extracting x,y positions