added state initialization function
added state fini functions