Refactor _ignore function for performance and readability