refactoring bar building functions