refactoring and beautification