refactor message code and maskfield