use atomic instead of channels