refactored bool code