refactoring and fixed inconsistent indent