Fixing socket delete error