broken wandering algorithm