added in checks to make sure that quality is above minimal threshold, and below maximal threshold