refactored printing library