Refactoring a couple of functions, renaming to make them more meaningful