finishing the code of chat