Refactoring

Small code review and refactoring