flipArray now takes a boolean