code refactoring, optimization, step 1