refactor for cleaner code