use tonumber(x) instead of type(x) == "number"; this covers all kinds of cdata number types and is about the same fast