error could be nil which cannot be casted