Added edge-of-building detection