I'd push the below in a dedicated function, `main` is long enough as is.