Refactored API to send message