DRYed; also: assign new variables only if necessary
js for previous commit