cleaning code and adding comments