Added locale, refactored code