add comments + clean up code