refactor code: exact cube as a class