added a flip array function