refactor code and add comments
add locale switch