case-mangle code now working properly