Refactored set_language