fixed main procedue