cleaned some of the code and removed old unused parts