Fixed bug in foldIR not working properly