code cleaned and  commented