Made some changes in rankOfMatrix function. I guess there is there is no need to implement it completely.