Ensured that JS cycle is only executed when ther are more than one image