Fix type assertion bug