Fix tunnel function