Add some check. Logic needs slightly rework.