scoped internal functions