Calculating Determinant of a Matrix