added toArray() and test