Fixes the logic