refactor within index.ts