Refactor for cleaner code and clarity