added the overflow check