How to write a loader