Refactor chatMsg and pm methods