1st Version of main code