Fixed escaping algorithm