Circular path detection added and some new modification,so code broke trying to find the error