Refactored population distribution into separate function