fix indexing function and add neighborhood model