Refactor collections.ts