Refactor for cleaner code