// Based on the example 3 from galleriffic