generalizing the function wrapper
forgot some stuff