refactored code into modules and reusable functions; added energy distribution; testing bdt viability of separation