refactored gatherInfo function