refactored a little and added some a check to prevent random switching to non gifs in the folder