Made some optimizations to the recSM_Solver function