copied util methods from CubeEngine