naive implementation