adding the before filter functionality