Solving Flatenning problem