second naive implementation