code works, need cleaning and comments