refactoring and beautifying