attempting flatten method for array