implement main functions