Updating length to handle arrays, objects, and strings