internal refactoring to improve readibility