added compare function and test case