added function for boundary extraction