State switching implemented