Updated with new type safety