small refractors
clean up and reworking of code