Added some code to handle arrays