trace
trace
optimize
c++ implemenatation