Slightly changed logic in add cycle function.