Speed up of determinant calculation