Matrix exercise | 2nd iteration