validation code for Dagmars R-program