added select pivot and test array building