adding array and refactoring printing