rearrange code

Change-Id: Ia7cb19e81c976ffbec8fa81b350dd37f9e3c4363
Add flag for gif animation

Change-Id: I107942f016d41ddc60d2375c9ea6f5db5f914e26