Added index handling so view can be reused