small refactor of messaging api