allmost all rewrite; checking input; reformatting; etc.