added filter functionality to printing
refactored