Refactor status message code