refactor flickr api code