refactored out duplicate add to array statements