Must stop reusing "stmt", because if it gets reused deeper it messes up external loop.