Added error handling in draw_edges for debugging