1. fixed broken logic
2. using numpy.array instead of array.array