genericized the code for contribution