# within the 1 second timeout, maybe the value of your variable currentAlgorithm changes somewhere else in your code?