refactored bfCmp