Move this repeated calculation out to a helper function.