fixed cube bug, updated logic in cube template