replace deprecated compiler flatten function