Added condition is compareTo to check if we are in the correct state