added code from in-class demo