refactored handletunnelloops
refactored handletunnelloops