fix small bug and clean up
use built-in comparison for pair