refactor portstat