improve countSolutions & correct syntax