old code integrated to the state pattern