added another function that uses atomics instead of channels with slight speedup