Making infinite loop optional