update logic and tests