Refactored to create partials and page states