added base logic and some tests