Refactor code structure for improved readability and maintainability
