refactoring and initial analysis updated