the final version adding some comments#