improved edge moving but there are still problems with intersection of curve and rectangle