fixing bug with matrix transpose