implement main logic