refactoring & clean-up part 2
refactoring and clean-up, part 3