Added quality validation in set_quality