fixing #58 by flatten the array