main functions and scripts