first working version of fgroup.py