adding surrounding elimination function