make replace and sum work together