refactors for efficiency