reorder array and tidy up some more formatting