error fixed and OOP style changes