code refactoring and readability enchanced