refactoring output method in game of life