main function - part 1