refactoring in preparation for arrays