fixed main bugs