improve comments and change some variable names