Fixed overflow check