commented out & made simpler

refactered code and added annotations.