refactor key and message