Eliminated redundancy in determine matrix sizes