some more testing, performance tuning
removed object.isPrimitive, because it is needless