introducing socket io and refactoring