refactoring and code indentation