overhauled version using new sock extension