simplified the puts/gets chain and shortened other statements