def scale_val(val, factor, direction):
    """Scale val by factor either 'up' or 'down'."""
    if direction == 'up':
        return val+(val*factor)
    if direction == 'down':
        return val-(val*factor)
    raise ValueError('direction must be "up" or "down"')