refactoring and indenting