improvement on class encapsulation and new sample examples