Refactor Music Box code