refactor neuron distribution into a separate function
beautify the code