refactoring and code updates
more refactoring