switching the code to use views