Refactor for better config