chap5: done
chap5: works on state