externalize functions