add state pattern and related notes