cleaned and added better comments