Implement main logic