fixed main function