change function values to z wherever possible