removed array access and added toArray()