move private functions to top of file