further fixed the logic mistake