reimplement with haxe template