Corrected the y calculation method