CUBA example running but not correct or efficient