Added a recurwsive function for array