Chat History logic implementation