Implement main function