code cleaned and finished