improve query efficiency by minimising object creation and modification
exclude IPs
refactor for speed and readability
reformat and update