refactored bubbleMap code