refactor core and add examples