fixed main code