complete main functions