fixed logic in geometry routine for calc_routine, test case still has issues but is getting better