commented and clean up code