Minor modification to the x calculation, also added rounding for calculations.