moved distribute part to .cpp file