revised some to get rid of extraneous code