Wrote calculations for core data