Integrated the not bad becomes good algorithm in python