refactored & added some example code