small modifications and add comments