Fix clang warning

Clang doesn't seem to like defining a function within a function.