implement index by function