Refactor left_right_compare method