move escape code to js