refactoring to remove dependency on separate label propagation routine and adding documentation