Adding implementation of flatten()