refactor message register and decode