move the flash message retrieval into layout