Repaired insert and implemented toArray()