Tried to define calcIndex and find, but failed.