Fix type assertion so we don't crash in runtime