Modify quick.groovy to fix a bug and refactor