Use newval instead of f.