trick to find rank of matrix