rewrote loader code