beginning of the chat history implementation