add fcn grouping and sql for find first protocol from pos