extraneous printlns deleted