started rewriting with socket