refactor create index functions