refactoring for my sanity