improved the escaped function