added some sanity check to filter parameters to prevent crashes