final and tested version of loader