Refactored lang function.