Add logic and tests