added anti-stuck behaviour