try to move qual_max 40 to outside