quarry.lua rewrite to function