restructured and refactored the messagemodel