to implement the calc algorithm, firstly implemented the compare functions( not complete yet)