fixed main function and setmode alittle