implement initialization and state reset