group available port finding logic in a class and add a new config option