Refactor, extract method handle_received_message