more idiomatic error handling