Improved matrix comprehension