main func modified