added flatten to Core