change indentation, do some refactoring