Updated the code to fix an issue with mangle