Added method flatten()