Object-oriented version
Complete changes