Refactored based on feedback from bbloom.