Further re-factoring for performance