move functions to file instead of end of index.