Fixed a number of syntax issues specifically relating to setting the qualitylevel variable.  In addition the wrong variable was being used in the actual execution.
Removed the echo command on line 31 which was being used for debugging.