added example page
refactored the code to use closures for proper encapsulation