Added check for errors