more structured code
refactoring