refactor for additional type safety and clarity