Naive implementation in Dart