rewrite of build_message