modified fns.lua