some code refactoring for a slightly smoother experience