Refactor to have transpose in a button

and also the array middle result kept in scope