This needs to be

    var touches = (event.changedTouches && event.changedTouches.length) ? event.changedTouches :
     ((event.touches && event.touches.length) ? event.touches : [event]);

For this function to work.