Optimize the code for flatters