Refactor `loadAll` and `load` functions