adding encirclement function