Updated main program to real working version