Initial version of main function