fixed minor bugs in loading logic