refactored loader to use file object