finish naive implementation