base logic