Tried to solve failed test cases. Kindly review a patch.