added a view-model
everything finally works!
code tidy up