making the js DRY