formatting and added the edge weight level condition