Port util to lua 5.2