modified fof.py