shifting code to implementation.py
minor tweaks