rename functions and variable and restructure