main functions complete