adding flip image functionality