Fixed refference error and added loading gif