Added error-checking code.