DRY up some js