fix a crash on optimizations