Refactor namespace 'require' logic to DRY