Refactored to make filters possible.