new verison of main function