add chatcore, and apply state design pattern