fixing escaping being in wrong order
more escaping, adding error state