More refactoring and modification