Fix logic and quoting