Added check of return code