eased recursion and added proper array output