adding chat logic