Trying to make cpp code return state space