update indexing; refactor index code into its class