added column major order algorithm