Added the verify_data_msg and reshuffled the definition of common functions