fixed main bug