Conversion to use OOP in the function..

Now it's easy, really :P