changed permute to transpose
add apply_recursive method