updated to improve performance - much better