refactor flash in layout