Fix the logic