Refactored language handling