Cleaned up the receiveMessage() method.