added socket closing