Added additional conditions to improve stability