added a mush better state pattern