Refactored beautify