made more modular and add example