third attempt to fix trail code