added an exception class that is  thrown when a cycle is found