fix memmory managment error