Improved boundary finding
Boundary algorithm