Refactor into views and passing data