fix potential issue with `cb` being called more than once