Move these subs out of the handle function to avoid redefining them every time this is triggered.