code cleaned and updated