Fixed empty matrix code