organized my edits to Wei's original's a bit better - modified to use local copu of cof file