adapting second example to use collections and models