[nim] Refactoring