updating code for 2nd edition!