adding fix for address already in use bug

Please review the changes.