Clean up code and add example