Converted to TypeScript