Helper function for bandpass filter