Implementation of determinant