Added more state switching