Encapsulated code into a class