clean up and commented new code