Extract set indirect path logic to function