refactored and improved bit bucket performance