Fully functional naive implementation