Improve error checking code style