cleaned all the codes, added doc