code formatting, refactoring & comments