mainfunction