Changed calculations

Changed the calculations for speed improvements