refactor index function, data model is less complex now