main function - part 2