updated code using class example.