refactor message type dispatch