clean, commented, somewhat polished