added tricky edge iteration to polygon