complete main functions.