refactoring for more logical