added a init and a exit function
impoved init/exit