finished functions to handle messages