new modifications and refactoring