almost there for the optimal control thing