fix logic for average determinant math