Revised Matrix transpose code to use for double loop