fix small mistake in the has-cycle function