cleaned more codes and added more comments