Added Compare Magnitude Function