added check for leading zeroes in b to the solve() method to make matrix inversions more efficient