Pass in phi implementation instead of declaring within fn.