added loading indicator function