cleanup comparison function