Refactor cube creation. Move cube creation logic into a separate method.