improve loader function