changed enforcing q values decreasing sequence code