Use type assertion for detecting error