refactor: refact the flash_message method