implemented compute_penances algorithm