Yang: refactor code