fix: avoid creating arrays more than once