almost fully function, need to finalize destroy