improved tunnel script