new method to detect x and y