Move those functions so they can be reused