make sure cb is a function before using it as such