Updated transpose function