Fix dangling edge problem