Using nested functions to avoid exposing inner helpers