add example dir and modularise code