Fixed some incorrect arithmetic