updated to handle escape characters