added failchecks and commentation