Refactor configure logic for better readability