move global functions to bottom