correcting processfn logic