Refactor get_gif method