updated cube code