optimized bre_input and bre_compare