constructor fixed to not crash destructor