refactor for haxe3