refactored to remove all local variables
extracted methods for all hash filtering