Change code to object oriented