refactor cube initialization