reorganize code, add nearby list