using model to store state
final version