entrance function refactory