fix broken code, and add comments