change to use factory function (handles different file types)