refactor ws