basic logic and tests