added loading logic