some light refactoring