Refactor of printPositions