Updated example and moved  into class