refactor of getmsg