finished commenting all the code, now we can understand it as a whole