some code refactoring (simplifying)