add inner functions
to do: add more inner functions