correcting how to calculate x and y