DRYing JS