handle replies with a custom function