finished base logic