basic logic rewritten