porting to dart(still not works)