fix quotation and when clause