cleaned and rewrote some stuff