altered helper to allow different array formats