Added stop condition for smart version.