refactored Chat sample
refactored Chat sample