refine code, now tuning!