fixed a bug in loader logic