Update gifify function, add some comments