streamlined the loadfile function