refactoring and space corrections