Adding loading gif and loading logic