applied more refactorings to enable reuse