fix overflow in comparison