fixing c++ solution