function renamed and unneeded variables removed