fix a bug: change PER_PORT to PER_PERIOD