New version with array