fifth attempt to fix trail code