fix issue handling integer overflow