main impl