annotated, removed excess code