Work-in-progress version for debugging
First version, need to investigate rounding error in calculation