refactor to better handle sigle message sending function