add some functions to decreaese the size of main function