Replacing for loop with Numpy maneuver

Replaced a for loop with an efficient Numpy array maneuver