logic + tests